<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Phar file stub</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="phar.fileformat.ingredients.html">Ingredients of all Phar archives, independent of file format</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="phar.fileformat.comparison.html">Head-to-head comparison of Phar, Tar and Zip</a></div>
 <div class="up"><a href="phar.fileformat.html">What makes a phar a phar and not a tar or a zip?</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="phar.fileformat.stub" class="section">
 <h2 class="title">Phar file stub</h2>
 <p class="para">
  A Phar&#039;s stub is a simple PHP file.  The smallest possible stub follows:
 </p>
 <p class="para">
  <div class="example-contents">
   <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">__HALT_COMPILER();</span>
</span>
</code></div>
  </div>

 </p>
 <p class="para">
  A stub must contain as a minimum, the <em>__HALT_COMPILER();</em> token
  at its conclusion.  Typically, a stub will contain loader functionality
  like so:
 </p>
 <p class="para">
  <div class="example-contents">
   <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">mapPhar</span><span style="color: #007700">();<br />include&nbsp;</span><span style="color: #DD0000">'phar://myphar.phar/index.php'</span><span style="color: #007700">;<br />__HALT_COMPILER();</span>
</span>
</code></div>
  </div>

 </p>
 <p class="para">
  There are no restrictions on the contents of a Phar stub, except for the requirement
  that it conclude with <em>__HALT_COMPILER();</em>.  The closing PHP tag
  <em><div class="cdata"><pre>?&gt;</pre></div></em> may be included or omitted, but there can be
  no more than 1 space between the <em>;</em> and the close tag
  <em><div class="cdata"><pre>?&gt;</pre></div></em> or the phar extension will be unable
  to process the Phar archive&#039;s manifest.
 </p>
 <p class="para">
  In a tar or zip-based phar archive, the stub is stored in the
  <em>.phar/stub.php</em> file.  The default stub for phar-based
  Phar archives contains approximately 7k of code to extract the contents
  of the phar and execute them.  See <span class="function"><a href="phar.createdefaultstub.html" class="function">Phar::createDefaultStub()</a></span>
  for more detail.
 </p>
 <p class="para">
  The phar alias is stored in a tar or zip-based phar archive in the
  <em>.phar/alias.txt</em> file as plain text.
 </p>
 </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="phar.fileformat.ingredients.html">Ingredients of all Phar archives, independent of file format</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="phar.fileformat.comparison.html">Head-to-head comparison of Phar, Tar and Zip</a></div>
 <div class="up"><a href="phar.fileformat.html">What makes a phar a phar and not a tar or a zip?</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
